package com.sun.boostrap.fallback;

import cn.hutool.json.JSONUtil;
import com.sun.boostrap.feign.OrderServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 服务降级处理
 */
@Component
@Slf4j
public class OrderServiceFallBackFactory  implements FallbackFactory<OrderServiceFeign> {

    private String method = "\n >>>>>[Method]:{}\n[request info]:{}\n[cause]:{}";

    @Override
    public OrderServiceFeign create(Throwable throwable) {
       return () -> {
           log.error(method,
                   "RPC>fallback>>OrderServiceFeign.selectOrderList", JSONUtil.toJsonStr(""),
                   throwable.getMessage());
           return null;
       };
    }
}
